// Angular Version 6 below need to be deleted {providedIn: 'root'}

// angular
import {Injectable} from '@angular/core';
import {HttpParams} from '@angular/common/http';
// owner
import {Request} from 'pengesoft-ng-lib';
// models
// import {any[]} from '../domains/any[].domain';
import {Reward} from '../domains/reward.domain';

/**
 * RewardServiceSvr
 */
@Injectable({
  providedIn: 'root'
})
export class RewardServiceSvr {
  baseUrl: string;

  constructor(
    private request: Request
  ){
    this.baseUrl = 'RewardServiceSvr.assx/';
  }

  /**
   * 
   */
  getRewardByEmpId(empId: string): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('empId', empId.toString());
    return this.request.post<any[]>(this.baseUrl + 'getRewardByEmpId', httpParams).then((res) => {
      return res;
    });
  }

  /**
   * 
   */
  addReward(reward: Reward): Promise<number>{
    const httpParams = new HttpParams()
      .append('reward', reward.toString());
    return this.request.post<number>(this.baseUrl + 'addReward', httpParams).then((res) => {
      return res;
    });
  }

  /**
   * 
   */
  GetVersion(): Promise<string>{
    const httpParams = new HttpParams();
    return this.request.post<string>(this.baseUrl + 'GetVersion', httpParams).then((res) => {
      return res;
    });
  }

  /**
   * 
   */
  delReward(rewardId: number): Promise<number>{
    const httpParams = new HttpParams()
      .append('rewardId', rewardId.toString());
    return this.request.post<number>(this.baseUrl + 'delReward', httpParams).then((res) => {
      return res;
    });
  }
}
